package com.qf.common.rocket.producer;

import com.qf.common.rocket.param.PointMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author zdl
 * @date 2025/4/15
 */
@Slf4j
@Component
public class Producer {
    @Resource
    private RocketMQTemplate rocketMQTemplate;
    public void sendPoint(PointMessage pointMessage){
        rocketMQTemplate.convertAndSend("point-topic",pointMessage);
    }

    public void sendCloseOrder(String orderNo) {
        // 发送延迟消息
        log.info("延迟发送消息 msg:{}", orderNo);
        // rocketmq 5.0 之后版本 可以任意指定延迟时间
        // 延迟时间 单位：毫秒
        rocketMQTemplate.syncSendDelayTimeSeconds("close-topic", orderNo, 30 * 60);
    }

}
